package com.cskaoyan.bean.sysmanage;

import com.cskaoyan.bean.Admin;
import com.github.pagehelper.PageInfo;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

@NoArgsConstructor
@Data
public class AdminPageData<T> {

    private Integer total;
    private Integer pages;
    private Integer limit;
    private Integer page;
    private List<T> list;

    @NoArgsConstructor
    @Data
    public static class AdminInfoBean {
        private Integer id;
        private String username;
        private String avatar;
        private List<Integer> roleIds;
    }

    public static <T> AdminPageData ok(List<T> list){
        PageInfo<T> adminPageInfo = new PageInfo<>(list);

        AdminPageData<T> adminPageData = new AdminPageData<>();
        adminPageData.setTotal(((int) adminPageInfo.getTotal()));
        adminPageData.setPages(adminPageInfo.getPages());
        adminPageData.setPage(adminPageInfo.getPageNum());
        adminPageData.setLimit(adminPageInfo.getPageSize());
        adminPageData.setList(list);

        return adminPageData;
    }
}
